#我想让他有个接口的作用

import pymongo
from pymongo import MongoClient

client = MongoClient('localhost',27017)
database = client['house'] #连接数据库
set = database['set']  #新建集合

class House(object):

    def __init__(self):     #初始化函数
        client = MongoClient('localhost',27017)
        database = client.house
        self._house = database.house

    def insert_one(self,house):    #插入一个
        return self._house.insert_one(house)

    def insert_many(self,house):    #插入多个
        return self._house.insert_many(house)

    def find(self):    #查找全部
        return self._house.find()

    def find_many(self,requirement):    #查找符合requirement的全部
        return self._house.find(requirement)

    def find_one(self,requirement):    #查找符合requirement的第一个
        return self._house.find_one(requirement)


if __name__ == '__main__':
    house = House()  #house对象

    #查找实例

    # print("---Find one---")
    # one_house = house.find_one({'zl_地址': '古城丁区 -古城汇金'})
    # print(one_house)
    # print("---------------\n")

    # print("---Find many---")
    # many_house = house.find_many({'zl_地址': '古城丁区 -古城汇金'})
    # for s in many_house:
    #     print(s)
    # print("---------------\n")]]


    # print("---Find all---")
    # all_house = house.find()
    # for s in all_house:
    #     print(s)
    # print("---------------\n")


